"""
    Extract user-submitted salary reports for all countries to Glassdoor.
"""

fileSeed = "C:/Users/jsock/Dropbox/Research/GD/International"

functionPathA = fileSeed + '/Replication/Functions'
functionPathB = "/" + fileSeed + '/Replication/Functions/'

savePath = fileSeed + "/Replication/Data/"

import sys
#sys.path.append('/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages')
sys.path.insert(0, functionPathA)
sys.path.insert(0, functionPathB)
from Function_extract_all_salaries import extractInternationalSalaries

import pymssql
import pandas as pd
import yaml
import os
import numpy as np
import scipy.stats as stats
import matplotlib.pyplot as plt
import csv
import statsmodels.api as sm

#Run to setup connection to Gandalf
config = yaml.load(open(os.path.expanduser('~/config.yaml')), Loader=yaml.FullLoader)
conn = pymssql.connect(**config.get('gandalf'))

print("Starting read from Gandalf")
dfInt = extractInternationalSalaries(conn, 0.85)

print("Starting write to CSV")
dfInt.to_csv(savePath + 'International_salaries_07_13_2022.csv', encoding='utf-8') # Encoding to dodge non-ASCII chars

